package com.hhl.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hhl.aop.ExtApiIdempotent;
import com.hhl.aop.ExtApiToken;
import com.hhl.entity.Order;
import com.hhl.mapper.OrderMapper;
import com.hhl.utils.ConstantUtils;

@Controller
public class OrderPageController {
	@Autowired
	private OrderMapper orderMapper;

	@RequestMapping("/index")
	@ExtApiToken
	public String index(HttpServletRequest req) {
		return "index";
	}

	@RequestMapping("/addOrder")
	@ExtApiIdempotent(type = ConstantUtils.EXTAPIFROM)
	public String addOrder(Order order) {
		int addOrder = orderMapper.insert(order);
		return addOrder > 0 ? "success" : "fail";
	}

}
